import ajax from './ajax';
import mockAjax from './mockAjax';

// 获取三级分类
export const reqGetCategoryListData = () => {
  return ajax.get('/product/getBaseCategoryList');
};

// 获取轮播数据
export const reqGetBannerListData = () => {
  return mockAjax.get('/bannerlist');
};

// 获取楼层数据
export const reqGetFloorListData = () => {
  return mockAjax.get('/floors');
};

// 获取搜索页面数据
export const reqPostSearchListData = params => {
  return ajax.post('/list', params);
};

// 获取商品详情页面数据
export const reqGetGoodsListData = skuId => {
  return ajax.get(`/item/${skuId}`);
};

// 获取添加商品到购物车或更新购物车
// /api/cart/addToCart/{ skuId }/{ skuNum }
export const reqPostAddOrUpdateCart = (skuId, skuNum) => {
  return ajax.post(`/cart/addToCart/${skuId}/${skuNum}`);
};

// 获取商品购物车数据
export const reqGetShopCartInfo = () => {
  return ajax.get('/cart/cartList');
};

// 获取购物车切换商品选中状态
export const reqGetShopCartisCheckedInfo = (skuID, isChecked) => {
  return ajax.get(`/cart/checkCart/${skuID}/${isChecked}`);
};

// 获取购物车全选状态
export const reqPostShopCartisCheckedAllInfo = (skuIdList, isChecked) => {
  return ajax.post(`/cart/batchCheckCart/${isChecked}`, skuIdList);
};

// 删除购物车一条商品信息
export const reqDelShopCartOneInfo = skuId => {
  return ajax.delete(`/cart/deleteCart/${skuId}`);
};

// 删除购物车多条商品信息
export const reqDelSelectShopCartInfo = skuIdList => {
  return ajax.post('/cart/batchDeleteCart', skuIdList);
};

// 获取验证码
export const reqGetPhoneCode = phone => {
  return ajax.get(`/user/passport/sendCode/${phone}`);
};

// 注册用户
export const reqGetEnrolluser = user => {
  return ajax.post('/user/passport/register', user);
};

// 登录用户
export const reqPostLoginUser = user => {
  return ajax.post('/user/passport/login', user);
};

// 退出登录
export const reqGetquitLogin = () => {
  return ajax.get('/user/passport/logout');
};

// 获取订单交易信息（结算）
export const reqGetTradeListData = () => {
  return ajax.get('/order/auth/trade');
};

// 获取用户收货地址信息
export const reqGetUserAddressList = () => {
  return ajax.get('/user/userAddress/auth/findUserAddressList');
};

// 提交订单接口
export const reqPostsubmitOrder = (tradeNo, params) => {
  return ajax.post(`/order/auth/submitOrder?tradeNo=${tradeNo}`, params);
};

// 获取订单支付信息，立即支付
export const reqGetPaymentInfo = orderId => {
  return ajax.get(`/payment/weixin/createNative/${orderId}`);
};

// 查询支付订单状态
export const reqGetPayStateInfo = orderId => {
  return ajax.get(`/payment/weixin/queryPayStatus/${orderId}`);
};

// 获取订单中心数据
export const reqGetCenterListData = (page, limit) => {
  return ajax.get(`/order/auth/${page}/${limit}`);
};
